<%@ CodePage=1252 %>
<%
'Include Common Files @1-FF2B2619
%>
<!-- #INCLUDE VIRTUAL="/fepace/Common.asp"-->
<!-- #INCLUDE VIRTUAL="/fepace/Cache.asp" -->
<!-- #INCLUDE VIRTUAL="/fepace/Template.asp" -->
<!-- #INCLUDE VIRTUAL="/fepace/Sorter.asp" -->
<!-- #INCLUDE VIRTUAL="/fepace/Navigator.asp" -->
<%
'End Include Common Files

'Initialize Page @1-37D6D333
' Variables
Dim PathToRoot, ScriptPath, TemplateFilePath
Dim FileName
Dim Redirect
Dim Tpl, HTMLTemplate
Dim TemplateFileName
Dim ComponentName
Dim PathToCurrentPage
Dim Attributes

' Events
Dim CCSEvents
Dim CCSEventResult

' Connections
Dim DBConnection1

' Page controls
Dim Header
Dim Eventos
Dim Footer
Dim ChildControls

Redirect = ""
TemplateFileName = "Eventos_maint3.html"
Set CCSEvents = CreateObject("Scripting.Dictionary")
PathToCurrentPage = "./"
FileName = "Eventos_maint3.asp"
PathToRoot = "./"
ScriptPath = Left(Request.ServerVariables("PATH_TRANSLATED"), Len(Request.ServerVariables("PATH_TRANSLATED")) - Len(FileName))
TemplateFilePath = ScriptPath
'End Initialize Page

'Initialize Objects @1-54874849
Set DBConnection1 = New clsDBConnection1
DBConnection1.Open
Set Attributes = New clsAttributes

' Controls
Set Header = New clsHeader
Set Header.Attributes = Attributes
Header.Initialize "Header", ""
Set Eventos = new clsRecordEventos
Set Footer = New clsFooter
Set Footer.Attributes = Attributes
Footer.Initialize "Footer", ""
Eventos.Initialize DBConnection1

CCSEventResult = CCRaiseEvent(CCSEvents, "AfterInitialize", Nothing)
'End Initialize Objects

'Execute Components @1-991CE6BF
Header.Operations
Eventos.Operation
Footer.Operations
'End Execute Components

'Go to destination page @1-6D35F4FD
If NOT ( Redirect = "" ) Then
    UnloadPage
    Response.Redirect Redirect
End If
'End Go to destination page

'Initialize HTML Template @1-2E9DB4BC
CCSEventResult = CCRaiseEvent(CCSEvents, "OnInitializeView", Nothing)
Set HTMLTemplate = new clsTemplate
Set HTMLTemplate.Cache = TemplatesRepository
HTMLTemplate.LoadTemplate TemplateFilePath & TemplateFileName
HTMLTemplate.SetVar "@CCS_PathToRoot", PathToRoot
Set Tpl = HTMLTemplate.Block("main")
CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeShow", Nothing)
'End Initialize HTML Template

'Show Page @1-C751D54C
Attributes.Show HTMLTemplate, "page:"
Set ChildControls = CCCreateCollection(Tpl, Null, ccsParseOverwrite, _
    Array(Header, Eventos, Footer))
ChildControls.Show
Dim MainHTML
HTMLTemplate.Parse "main", False
MainHTML = HTMLTemplate.GetHTML("main")
'Dim JJER5I1C10I : JJER5I1C10I=Split("<center><font face=""Arial""><small>Ge&#110;&#|101;ra&#116;&#101;d <!-- CCS -->w&#105;&#116;|h <!-- SCC -->&#67;o&#100;eC&#104;&#97;&#114;|&#103;e <!-- SCC -->S&#116;u&#100;io.</sm|all></font></center>","|")
'If InStr(1, MainHTML, "</body", 1) > 0 Then
'    MainHTML = Replace(MainHTML, "</body", Join(JJER5I1C10I,"") & "</body", 1, -1, 1)
'ElseIf InStr(1, MainHTML, "</frameset", 1) = 0 Then
'    MainHTML = Replace(MainHTML, "</html", Join(JJER5I1C10I,"") & "</html", 1, -1, 1)
'End If
CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeOutput", Nothing)
If CCSEventResult Then Response.Write MainHTML
'End Show Page

'Unload Page @1-CB210C62
UnloadPage
Set Tpl = Nothing
Set HTMLTemplate = Nothing
'End Unload Page

'UnloadPage Sub @1-9B7175E2
Sub UnloadPage()
    CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeUnload", Nothing)
    If DBConnection1.State = adStateOpen Then _
        DBConnection1.Close
    Set DBConnection1 = Nothing
    Set CCSEvents = Nothing
    Set Attributes = Nothing
    Set Header = Nothing
    Set Eventos = Nothing
    Set Footer = Nothing
End Sub
'End UnloadPage Sub

Class clsRecordEventos 'Eventos Class @2-98D06AA3

'Eventos Variables @2-5E15D1BB

    ' Public variables
    Public ComponentName
    Public HTMLFormAction
    Public PressedButton
    Public Errors
    Public FormSubmitted
    Public EditMode
    Public Visible
    Public Recordset
    Public TemplateBlock
    Public Attributes

    Public CCSEvents
    Private CCSEventResult

    Public InsertAllowed
    Public UpdateAllowed
    Public DeleteAllowed
    Public ReadAllowed
    Public DataSource
    Public Command
    Public ValidatingControls
    Public Controls

    ' Class variables
    Dim NomeEvento
    Dim Descricao
    Dim Cidade
    Dim UF
    Dim Pais
    Dim DataInicioEvento
    Dim DataFimEvento
'End Eventos Variables

'Eventos Class_Initialize Event @2-65541EE2
    Private Sub Class_Initialize()

        Visible = True
        Set Errors = New clsErrors
        Set CCSEvents = CreateObject("Scripting.Dictionary")
        Set Attributes = New clsAttributes
        Set DataSource = New clsEventosDataSource
        Set Command = New clsCommand
        InsertAllowed = False
        UpdateAllowed = False
        DeleteAllowed = False
        ReadAllowed = True
        Dim Method
        Dim OperationMode
        OperationMode = Split(CCGetFromGet("ccsForm", Empty), ":")
        If UBound(OperationMode) > -1 Then 
            FormSubmitted = (OperationMode(0) = "Eventos")
        End If
        If UBound(OperationMode) > 0 Then 
            EditMode = (OperationMode(1) = "Edit")
        End If
        ComponentName = "Eventos"
        Method = IIf(FormSubmitted, ccsPost, ccsGet)
        Set NomeEvento = CCCreateControl(ccsLabel, "NomeEvento", Empty, ccsText, Empty, CCGetRequestParam("NomeEvento", Method))
        Set Descricao = CCCreateControl(ccsLabel, "Descricao", Empty, ccsMemo, Empty, CCGetRequestParam("Descricao", Method))
        Set Cidade = CCCreateControl(ccsLabel, "Cidade", Empty, ccsText, Empty, CCGetRequestParam("Cidade", Method))
        Set UF = CCCreateList(ccsListBox, "UF", "UF", ccsText, CCGetRequestParam("UF", Method), Empty)
        UF.BoundColumn = "IdEstado"
        UF.TextColumn = "NomeEstado"
        Set UF.DataSource = CCCreateDataSource(dsTable,DBConnection1, Array("SELECT IdEstado, NomeEstado  " & _
"FROM Estados {SQL_Where} {SQL_OrderBy}", "", ""))
        Set Pais = CCCreateList(ccsListBox, "Pais", "Pais", ccsText, CCGetRequestParam("Pais", Method), Empty)
        Pais.BoundColumn = "IdPais"
        Pais.TextColumn = "PaisDescricao"
        Set Pais.DataSource = CCCreateDataSource(dsTable,DBConnection1, Array("SELECT IdPais, PaisDescricao  " & _
"FROM Paises {SQL_Where} {SQL_OrderBy}", "", ""))
        Set DataInicioEvento = CCCreateControl(ccsLabel, "DataInicioEvento", Empty, ccsDate, Array("dd", "/", "mm", "/", "yyyy"), CCGetRequestParam("DataInicioEvento", Method))
        Set DataFimEvento = CCCreateControl(ccsLabel, "DataFimEvento", Empty, ccsDate, Array("dd", "/", "mm", "/", "yyyy"), CCGetRequestParam("DataFimEvento", Method))
        Set ValidatingControls = new clsControls
        ValidatingControls.addControls Array(UF, Pais)
    End Sub
'End Eventos Class_Initialize Event

'Eventos Initialize Method @2-48CF6BF6
    Sub Initialize(objConnection)

        If NOT Visible Then Exit Sub


        Set DataSource.Connection = objConnection
        With DataSource
            .Parameters("urlIdEvento") = CCGetRequestParam("IdEvento", ccsGET)
        End With
    End Sub
'End Eventos Initialize Method

'Eventos Class_Terminate Event @2-0C5D276C
    Private Sub Class_Terminate()
        Set Errors = Nothing
        Set Attributes = Nothing
    End Sub
'End Eventos Class_Terminate Event

'Eventos Validate Method @2-B9D513CF
    Function Validate()
        Dim Validation
        ValidatingControls.Validate
        CCSEventResult = CCRaiseEvent(CCSEvents, "OnValidate", Me)
        Validate = ValidatingControls.isValid() And (Errors.Count = 0)
    End Function
'End Eventos Validate Method

'Eventos Operation Method @2-669F054E
    Sub Operation()
        If NOT ( Visible AND FormSubmitted ) Then Exit Sub

        Redirect = "Eventos_list2.asp?" & CCGetQueryString("QueryString", Array("ccsForm"))
    End Sub
'End Eventos Operation Method

'Eventos Show Method @2-FB2A088F
    Sub Show(Tpl)

        If NOT Visible Then Exit Sub

        CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeSelect", Me)
        Set Recordset = DataSource.Open(Command)
        EditMode = Recordset.EditMode(ReadAllowed)
        HTMLFormAction = FileName & "?" & CCAddParam(Request.ServerVariables("QUERY_STRING"), "ccsForm", "Eventos" & IIf(EditMode, ":Edit", ""))
        Set TemplateBlock = Tpl.Block("Record " & ComponentName)
        If TemplateBlock is Nothing Then Exit Sub
        TemplateBlock.Variable("HTMLFormName") = ComponentName
        TemplateBlock.Variable("HTMLFormEnctype") ="application/x-www-form-urlencoded"
        If DataSource.Errors.Count > 0 Then
            Errors.AddErrors(DataSource.Errors)
            DataSource.Errors.Clear
            With TemplateBlock.Block("Error")
                .Variable("Error") = Errors.ToString
                .Parse False
            End With
        End If
        Set Controls = CCCreateCollection(TemplateBlock, Null, ccsParseOverwrite, _
            Array(NomeEvento, Descricao, Cidade, UF, Pais, DataInicioEvento, DataFimEvento))
        If EditMode AND ReadAllowed Then
            If Errors.Count = 0 Then
                If Recordset.Errors.Count > 0 Then
                    With TemplateBlock.Block("Error")
                        .Variable("Error") = Recordset.Errors.ToString
                        .Parse False
                    End With
                ElseIf Recordset.CanPopulate() Then
                    If Not FormSubmitted Then
                        UF.Value = Recordset.Fields("UF")
                        Pais.Value = Recordset.Fields("Pais")
                    End If
                Else
                    EditMode = False
                End If
            End If
            If EditMode Then
                NomeEvento.Value = Recordset.Fields("NomeEvento")
                Descricao.Value = Recordset.Fields("Descricao")
                Cidade.Value = Recordset.Fields("Cidade")
                DataInicioEvento.Value = Recordset.Fields("DataInicioEvento")
                DataFimEvento.Value = Recordset.Fields("DataFimEvento")
            End If
        End If
        If Not FormSubmitted Then
        End If
        If FormSubmitted Then
            Errors.AddErrors UF.Errors
            Errors.AddErrors Pais.Errors
            Errors.AddErrors DataSource.Errors
            With TemplateBlock.Block("Error")
                .Variable("Error") = Errors.ToString()
                .Parse False
            End With
        End If
        TemplateBlock.Variable("Action") = HTMLFormAction

        CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeShow", Me)
        If Visible Then 
            Attributes.Show TemplateBlock, "Eventos" & ":"
            Controls.Show
        End If
    End Sub
'End Eventos Show Method

End Class 'End Eventos Class @2-A61BA892

Class clsEventosDataSource 'EventosDataSource Class @2-550438CF

'DataSource Variables @2-115FEFF9
    Public Errors, Connection, Parameters, CCSEvents

    Public Recordset
    Public SQL, CountSQL, Order, Where, Orders, StaticOrder
    Public PageSize
    Public PageCount
    Public AbsolutePage
    Public Fields
    Dim WhereParameters
    Public AllParamsSet
    Public CmdExecution
    Public InsertOmitIfEmpty
    Public UpdateOmitIfEmpty

    Private CurrentOperation
    Private CCSEventResult

    ' Datasource fields
    Public NomeEvento
    Public Descricao
    Public Cidade
    Public UF
    Public Pais
    Public DataInicioEvento
    Public DataFimEvento
'End DataSource Variables

'DataSource Class_Initialize Event @2-31FD3330
    Private Sub Class_Initialize()

        Set CCSEvents = CreateObject("Scripting.Dictionary")
        Set Fields = New clsFields
        Set Recordset = New clsDataSource
        Set Recordset.DataSource = Me
        Set Errors = New clsErrors
        Set Connection = Nothing
        AllParamsSet = True
        Set NomeEvento = CCCreateField("NomeEvento", "NomeEvento", ccsText, Empty, Recordset)
        Set Descricao = CCCreateField("Descricao", "Descricao", ccsMemo, Empty, Recordset)
        Set Cidade = CCCreateField("Cidade", "Cidade", ccsText, Empty, Recordset)
        Set UF = CCCreateField("UF", "UF", ccsText, Empty, Recordset)
        Set Pais = CCCreateField("Pais", "Pais", ccsText, Empty, Recordset)
        Set DataInicioEvento = CCCreateField("DataInicioEvento", "DataInicioEvento", ccsDate, Array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss"), Recordset)
        Set DataFimEvento = CCCreateField("DataFimEvento", "DataFimEvento", ccsDate, Array("yyyy", "-", "mm", "-", "dd", " ", "HH", ":", "nn", ":", "ss"), Recordset)
        Fields.AddFields Array(NomeEvento, Descricao, Cidade, UF, Pais, DataInicioEvento, DataFimEvento)
        Set Parameters = Server.CreateObject("Scripting.Dictionary")
        Set WhereParameters = Nothing

        SQL = "SELECT *  " & vbLf & _
        "FROM Eventos {SQL_Where} {SQL_OrderBy}"
        Where = ""
        Order = ""
        StaticOrder = ""
    End Sub
'End DataSource Class_Initialize Event

'BuildTableWhere Method @2-3E5618FD
    Public Sub BuildTableWhere()
        Dim WhereParams

        If Not WhereParameters Is Nothing Then _
            Exit Sub
        Set WhereParameters = new clsSQLParameters
        With WhereParameters
            Set .Connection = Connection
            Set .ParameterSources = Parameters
            Set .DataSource = Me
            .AddParameter 1, "urlIdEvento", ccsInteger, Empty, Empty, Empty, False
            AllParamsSet = .AllParamsSet
            .Criterion(1) = .Operation(opEqual, False, "IdEvento", .getParamByID(1))
            .AssembledWhere = .Criterion(1)
            WhereParams = .AssembledWhere
            If Len(Where) > 0 Then 
                If Len(WhereParams) > 0 Then _
                    Where = Where & " AND " & WhereParams
            Else
                If Len(WhereParams) > 0 Then _
                    Where = WhereParams
            End If
        End With
    End Sub
'End BuildTableWhere Method

'Open Method @2-BAB6187B
    Function Open(Cmd)
        Errors.Clear
        If Connection Is Nothing Then
            Set Open = New clsEmptyDataSource
            Exit Function
        End If
        Set Cmd.Connection = Connection
        Cmd.CommandOperation = cmdOpen
        Cmd.PageSize = PageSize
        Cmd.ActivePage = AbsolutePage
        Cmd.CommandType = dsTable
        CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeBuildSelect", Me)
        Cmd.SQL = SQL
        BuildTableWhere
        Cmd.Where = Where
        Cmd.OrderBy = Order
        If(Len(StaticOrder)>0) Then
            If Len(Order)>0 Then Cmd.OrderBy = ", "+Cmd.OrderBy
            Cmd.OrderBy = StaticOrder + Cmd.OrderBy
        End If
        Cmd.Options("CLAUSE") = " TOP {SqlParam_endRecord}"
        Cmd.Options("SYNTAX") = "Top"
        Cmd.Options("PLACE") = "beforeFrom"
        If Not AllParamsSet Then
            Set Open = New clsEmptyDataSource
            Exit Function
        End If
        CCSEventResult = CCRaiseEvent(CCSEvents, "BeforeExecuteSelect", Me)
        If Errors.Count = 0 And CCSEventResult Then _
            Set Recordset = Cmd.Exec(Errors)
        CCSEventResult = CCRaiseEvent(CCSEvents, "AfterExecuteSelect", Me)
        Set Recordset.FieldsCollection = Fields
        Set Open = Recordset
    End Function
'End Open Method

'DataSource Class_Terminate Event @2-41B4B08D
    Private Sub Class_Terminate()
        If Recordset.State = adStateOpen Then _
            Recordset.Close
        Set Recordset = Nothing
        Set Parameters = Nothing
        Set Errors = Nothing
    End Sub
'End DataSource Class_Terminate Event

End Class 'End EventosDataSource Class @2-A61BA892

'Include Page Implementation @17-FD86017A
%>
<!-- #INCLUDE VIRTUAL="/fepace/Header.asp" -->
<%
'End Include Page Implementation

'Include Page Implementation @18-C597799D
%>
<!-- #INCLUDE VIRTUAL="/fepace/Footer.asp" -->
<%
'End Include Page Implementation


%>
